<template>
	<view>
		<div>
			<navitop>
				<i class="iconfont" slot="left-slot" @click="outlot">&#xe667;</i>
				<span slot="center-slot">{{name}}</span>
				<i class="iconfont icon-youcecaidan" slot="right-slot" v-show="add_show" @click="tapPopup(data)"></i>
			</navitop>
		</div>
 
		<div class="detial public_mag_top" >
			<!-- 头部公共简介 -->
			<div class="secode_uot" >
				<div class="secode_img">
					<!-- <div>
						<image src="../../../static/image/1.jpg"></image>
					</div> -->
					<div v-if="dataSorce.avatar">
						<image :src="dataSorce.avatar"></image>
					</div>
					<div class="secode_ph" v-else>
						<div>{{dataSorce.crmName}}</div>
					</div>
					<div class="secode_text">
						<div>{{dataSorce.crmName}}</div>
					</div>
				</div>
				<div class="secode_class">
					<div>
						<text>所属人：{{dataSorce.collarUserName}}</text>
					</div>
					<div v-if="dataSorce.street">
						<text>地&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;址：{{dataSorce.street}}</text>
					</div>
				</div>
				
			</div>
			<div style="width: 95%; margin: auto;">
				<v-tabs v-model="current" :scroll="scroll_one" line-height="0" pillsColor="#1296db" activeColor="#fff"
				:pills="true" :tabs="tabs" @change="changeTab"></v-tabs>
			</div>
			<div style="height: 15rpx;background-color: #f0f0f0;"></div>
			<!-- 基本信息 -->
			<div v-show="switch_one">
				<div class="detial_text" v-for="(item,index) in results">
					<div v-if="item.dataType == '1'">
						<text>{{item.name}}:</text>
						<text style="color: #000000;">{{item.value}}</text>
					</div>
					<div v-if="item.dataType == '2'">
						<text>{{item.name}}:</text>
						<text style="color: #000000;">{{item.values}}</text>
					</div>
				</div>
			</div>

			<!-- 联系人 -->
			<div v-if="switch_tow">
				<view v-for="(item,index) in contactname">
					<div class="conten">
						<div @click="contenedit(item.id)">
							<text>姓名：{{item.name}}</text>
							<text>性别：{{item.gender == '男' ? '男' : '女'}}</text>
						</div>
						<div @click="contenedit(item.id)">
							<text>部门：{{item.dept}}</text>
							<text>职务：{{item.position}}</text>
						</div>

						<div>
							<text class="conten_phone">手机号码：{{item.mobile}}</text><a :href="'tel:'+item.mobile"
								style="color: #000000;"><i class="iconfont icon-dianhua"
									style="float: right; margin-right: 10px;line-height: 70rpx;"></i></a>
						</div>
						<div>
							<text class="conten_phone">办公电话：{{item.officePhone}}</text><a
								:href="'tel:'+item.officePhone" style="color: #000000;"><i class="iconfont icon-dianhua"
									style="float: right; margin-right: 10px;line-height: 70rpx;"></i></a>
						</div>

					</div>
					<div class="div_h"></div>
				</view>
					<div class="null_title" v-if="contactname == ''">
						<div>
							<i class="iconfont icon-empty iconcize"></i>
						</div>
						<div class="null_title_tow">
							没有更多数据
						</div>
					</div>
			</div>

			<!-- 联系记录-->
			<div v-show="switch_three">
				<view class="record" v-for="(item,index) in record_name" @click="record_details(item)">
					
					<div v-if="item.type == 1" class="record_div_one" style="padding-top: 7px;">
						<view class="record_public" >
							<text>{{item.contactDate}}</text>
							<text class="record_public_text">会话沟通</text>
						</view>
						<view class="record_public record_dispaly record_text">
							<view>
								<text>业务员：</text><text>{{item.salesManName}}</text>
							</view>
							<view>
								<text>业务部门：</text><text>{{item.dept}}</text>
							</view>
						</view>
						<view class="record_txt">
							<navtxt style="word-wrap:break-word; word-break:normal;" :result="item.remarks"></navtxt>
						</view>
						<view class="record_public record_dispaly record_text">
							<view>
								<text>联系人：</text><text>{{item.linkManName}}</text>
							</view>
							<view>
								<text>联系方式：</text><text>{{item.touchType}}</text>
							</view>
						</view>
					</div>
					
					<div  v-else-if="item.type == 2" class="record_div_one">
						<view class="record_public" style="padding-top: 7px;">
							<text>{{item.contactDate}}</text>
							<text class="record_public_text">外勤签到</text>
						</view>
						<view class="record_public record_dispaly record_text">
							<view>
								<text>业务员：</text><text>{{item.salesManName}}</text>
							</view>
							<view>
								<text>业务部门：</text><text>{{item.dept}}</text>
							</view>
						</view>
						<view class="record_txt" style="padding-top: 2px;">
							<navtxt style="word-wrap:break-word; word-break:normal;" :result="item.remarks"></navtxt>
						</view>
						<div>
							<view class="record_public" v-if="item.visitSign">
								<i class="iconfont icon-weizhi" style="color: #007aff;padding-right: 10rpx;font-size: 20px; overflow: hidden;"></i><text>{{item.visitSign}}</text>
							</view>
						</div>
					</div>
					<!-- <view style="width: 100%;height: 5px; margin: 10rpx 0 0 0; background-color: #F0F0F0;"></view> -->
				</view>
				<!-- <div style="height: 70px;"></div>
				<div class="record_bottom"  >
					<div>
						<text @click="recorda()">写跟进</text>
						<text @click="recodesigns()">外勤签到</text>
					</div>
				</div> -->
				
				
				<div class="null_title" v-if="record_name == ''">
					<div>
						<i class="iconfont icon-empty iconcize"></i>
					</div>
					<div class="null_title_tow">
						没有更多数据
					</div>
				</div>
			</div>
		
			<!-- 商机 -->
			<div v-if="switch_five">
				<inbuslist :seturl="url" :rundataSorce="rundatas" :user_id='uid' :textname="name" :classid="class_id" :rmtype='action_id' @ruon="ruon"></inbuslist>
				<div class="null_title" v-if="rundatas == ''">
					<div>
						<i class="iconfont icon-empty iconcize"></i>
					</div>
					<div class="null_title_tow">
						没有更多数据
					</div>
				</div>
			</div>
		</div>

		<!-- 弹窗组件 -->
		<popus ref="popup">
			<div class="staff">
				<scroll-view class="staff_b" scroll-y="true" touch-action=none;>
					<div class="staff_list" v-for="(item,index) in staff" :style="item.id == color_id ? text_color : ''"
						@touchstart="setname(item)">
						{{item.name}}
					</div>
				</scroll-view>

				<view class="staff_button">
					<button @click="buttonput">确定</button>
				</view>
			</div>
		</popus>

		<!-- 外勤签到 -->
		<popus ref="recode">
			<div :style="alertWidth"> 
				<recodeSign :data="dataSorce" :url="url" @recodecolos="recodecolos"></recodeSign>
			</div>
		</popus> 
		
		<!-- 历史外勤签到显示 -->
		<popus ref="recodelist">  
			<div :style="alertWidth">
				<recodelist @recodlist="recodlist" :data="dataSorce"></recodelist>
			</div> 
		</popus>

		<!-- 商机添加 -->
		<popus ref="inbusadd">
			<div :style="alertWidth">
				<inbusadd :user_id='uid' :rmtype='action_id' :dsorce="dataSorce" :url="url" @inbusaddclose="inbusaddclose"></inbusadd>
			</div>
		</popus>

		<!-- 公用弹窗 -->
		<chunLeiPopups v-model="value" :popData="data" @tapPopup="tapPopup" :x="345" :y="95" placement="top-end">
		</chunLeiPopups>
		<popus ref="alert">
			<alertg @rundata="rundata"></alertg>
		</Popus>
	</view>
</template>

<script>
	import navitop from '@/components/common/navi-top'
	import navtxt from '@/pages/common/index/detial/detialtxt.vue'
	import popus from '@/uni_modules/uni-popup/components/uni-popup/uni-popup'
	import recodeSign from '@/pages/common/index/subpage/record/recordSign'
	import recodelist from '@/pages/common/index/subpage/record/recordlist'
	import inbuslist from '@/pages/common/index/subpage/inbusiness/inbuslist'
	import inbusadd from '@/pages/common/index/subpage/inbusiness/inbusadd'
	import {
		detail,
		delect,
		namelist,
		pages,
		list,
		collect,
		release,
		receive,
		UserList,
		dataList,
		butionSave,
		userdetail,
		dealSave,
		saveShare,
		potentialSave,
		pageList,
		getUserInfo
	} from '@/common/api/job/jobapi.js'
	import Vtabs from '@/components/common/navi-top'
	import alertg from '@/pages/common/common/alert/alertgx.vue'
	import chunLeiPopups from "@/components/chunLei-popups/chunLei-popups.vue"

	export default {
		components: {
			navitop,
			popus,
			Vtabs,
			chunLeiPopups,
			navtxt,
			alertg,
			recodeSign,
			recodelist,
			inbuslist,
			inbusadd
		},
		data() {
			return {
				dataSorce: [],
				uid: '',
				value: false,
				data: [],
				rundatas: [],
				current: 0,
				tabs: ['基本资料', '联系人', '跟进记录','商机管理','报价单'],
				latitude: '90',
				longitude: '80',
				scroll_one: false, //设置tabs选项是否平铺 
				switch_one: false, // 基本信息
				switch_tow: false, // 联系人
				switch_three: false, // 联系记录
				switch_four: false, // 报价单
				switch_five: false,//商机
				namelist: [],
				results: [],
				contactname: [], //联系人信息
				runt: [],
				staff: [], //员工列表
				text_color: '', // 分配选中
				color_id: '', // 选中id
				Select_name: '', // 选中人
				record_name: '', // 联系记录
				kehu_name: '', // 客户名称
				text_delit: '', // 点击显示剩余文字
				text_delits: '',
				text_click: false, // 点击是否显示剩余
				action_id: '', //联系人分类id
				class_id: '', // 分类id
				name: '', // 分类标题
				url: '',
				alertWidth: ''	,// 获取弹窗逐渐兼容宽度
				add_show: true,	// 权限控制显示
				citys:'',		// 客户地址
				pages: 1,		// 分页
				talindex: ''		,// 切换
				LcrmType: '',
				let_data: '',
			}
		},
		onLoad(option) {
			// 获取窗口宽度
			let _this = this;
			uni.getSystemInfo({
			    success: function (res) {
					_this.alertWidth = 'width:' + res.windowWidth + 'px;'
			    }
			});
			this.talindex = option.index;
			this.text_delit = 'public_click_text';
			this.uid = option.id;
			this.class_id = option.classid;
			this.action_id = option.crmType;
			this.name = option.name;
			this.LcrmType = option.LcrmType;
			this.url = '&classid=' + option.classid + '&crmType=' + option.crmType + '&name=' + option.name + '&index=' + option.index;
			if(option.index == 0){
				if (option.classid == 2) { //公海
					this.switch_data(option.crmType,this.class_id);
				}
				if (option.classid == 3) { //潜在
					this.switch_data(option.crmType,this.class_id);
				}
				if (option.classid == 1) { // 成交
					this.switch_data(option.crmType,this.class_id);
				}
			}
			// 按钮弹窗定位
			this.changeTab(option.index)
			detail({id: option.id}).then((row) => {
				if(row.code == 200){
					this.dataSorce = row.data;
					this.kehu_name = row.data.crmName;
					this.citys = row.data.street;
				}
			});
			// 员工列表
			dataList({isLoadUser: 2}).then((result) => {
				if(result.code == 200){
					for (let i in result.data) {
						if (result.data[i].id.split("_")[1]) {
							this.staff.push(result.data[i]);
						}
					}
				}
			});
			// 联系记录
			this.recordlist(this.pages);
			if (this.tabs.length > 5) {
				this.scroll_one = true;
			}
			// 基本信息
			this.listtile();
			// 联系人
			this.contact(this.pages);
			// 商机
			this.inbus_list(this.uid,this.action_id,this.pages);
		},
		
		//上拉加载监听方法
		onReachBottom: function(){
			let class_id = this.talindex;
			if(this.dataSorce.length >= 20){
				this.pages++;
				if(class_id == 1){
					this.contact(this.pages,1);
				}
				if(class_id == 2){
					this.recordlist(this.pages,1);
				}
				if(class_id == 3){
					this.inbus_list(this.uid,this.action_id,this.pages,1);
				}
			}
		},
		methods: {
			// 下拉刷新
			onPullDownRefresh() {
				let _this = this;
				setTimeout(function () {
					uni.stopPullDownRefresh();
					uni.redirectTo({
						url: '/pages/common/index/detial?id=' + _this.uid + _this.url
					});
				}, 1000);
			},

			// 权限控制
			get_userInfo(runData,class_fl){
				let sotrt = [];
				this.data = [];
				getUserInfo().then((rows) => {
					if(rows.code == 200) {
						rows.data.permissions.forEach(item => {
							runData.forEach(vals =>{
								if(item == vals.msag_code){
									sotrt.push(vals);
								}
							})
						})
					}
					if(sotrt == 0){
						this.add_show = false;
					}else {
						this.add_show = true;
					}
					if(class_fl == 2){
						// sotrt.push({title: "关注",messing: 'detialdel',code: 7,icon: 'icon-guanzhu',msag_code: '' });
						// sotrt.push({title: "取消关注",messing: 'detialdel',code: 9,icon: 'icon-quxiaoguanzhu',msag_code: '' });
					}
					this.data = sotrt;
					// this.rundatas = this.data;
				})
			},
			
			// 切换数据分配
			switch_data(crmType,classId){
				if(crmType == 0 ){ // 公海
					let sot = [
						{title: "编辑",messing: 'detialedit',code: 2,icon: 'icon-bianji',msag_code: 'crm:clue:detail:save' },
						{title: "领用",messing: 'detialdel',code: 4,icon: 'icon-lingyong',msag_code: 'crm:clue:receive' },
						{title: "分配",messing: 'detialdel',code: 5,icon: 'icon-fenpei',msag_code: 'crm:clue:distribution'},
						{title: "删除",messing: 'detialdel',code: 3,icon: 'icon-shanchu',msag_code: 'crm:clue:disable' },
					];
					this.get_userInfo(sot,crmType)
				}
				if(crmType == 2 ){ // 成交
					let sot = [
						{title: "编辑",messing: 'detialedit',code: 2,icon: 'icon-bianji',msag_code: 'crm:deals:detail:save' },
						{title: "分配",messing: 'detialdel',code: 5,icon: 'icon-fenpei',msag_code: 'crm:deals:distribution' },
						{title: "退回",messing: 'detialdel',code: 11,icon: 'icon-tuihui',msag_code: 'crm:deals:goBack' },
						{title: "删除",messing: 'detialdel',code: 3,icon: 'icon-shanchu',msag_code: 'crm:deals:disable' },
					];
					this.get_userInfo(sot,crmType)
				}
				if(crmType == 1 ){ // 潜在
					let sot = [
						{title: "编辑",messing: 'detialedit',code: 2,icon: 'icon-bianji',msag_code: 'crm:potential:detail:save' },
						{title: "成交",messing: 'detialdel',code: 12,icon: 'icon-chengjiaoguanli',msag_code: 'crm:potential:deal' },
						{title: "分配",messing: 'detialdel',code: 5,icon: 'icon-fenpei',msag_code: 'crm:potential:distribution' },
						{title: "释放",messing: 'detialdel',code: 6,icon: 'icon-shifang',msag_code: 'crm:potential:release' },
						{title: "删除",messing: 'detialdel',code: 3,icon: 'icon-shanchu',msag_code: 'crm:potential:disable' },
					];
					this.get_userInfo(sot,crmType)
				}
			},
			
			outlot() {
				if(this.LcrmType){
					this.action_id = this.LcrmType;
				}
				uni.navigateTo({
					url: '/pages/common/index/second?id=' + this.class_id + '&crmType=' + this.action_id +
						'&name=' + this.name
				})
			},
			contenedit(val) {
				uni.navigateTo({
					url: "/pages/common/index/contactedit?id=" + val + '&uid=' + this.uid + '&crmType=' + this
						.action_id + '&name=' + this.name + '&classid=' + this.class_id
				})
			},
			open() {
				this.$refs.popup.open('bottom')
			},
			setname(val) {
				this.Select_name = val;
				this.color_id = val.id;
				this.text_color = "color: #1890ff;";
			},
			txt_click(val) {
				this.text_click = val;
				if (val == this.text_click) {
					this.text_delit = '';
					this.text_click = val;
				}
				if (val !== this.text_click) {
					this.text_delit = 'public_click_text';
					this.text_click = val;
				}

			},
			// 分配确定
			buttonput() {
				let crm_Name = '';
				if (this.Select_name == '') {
					uni.showToast({
						title: "请选择被分配人",
						icon: 'error'
					})
					return false;
				}
				if(this.let_data.crmType == 0){
					crm_Name = 1;
				}else {
					crm_Name = this.let_data.crmType;
				}
				butionSave({
					type: crm_Name,
					collarUserId: this.Select_name.id.split("_")[0],
					collarUserName: this.Select_name.name,
					ids: this.uid 
				}).then((result) => {
					if (result.code == 200) {
						uni.showToast({
							title: "分配成功",
						})
						setTimeout(() => {
							this.text_color = "";
							this.$refs.popup.close()
						}, 1500)
					}
				})
			},
			// 分配取消
			buttonputput() { 
				this.text_color = "";
				this.$refs.popup.close()
			},
			// 客户基本信息
			listtile() {
				list({source: 'crm'}).then((rows) => {
					if (rows.code === 200) {
						detail({id: this.uid}).then((result) => {
							if (result.code == 200) {
								// console.log('88888888888',result)this.let_data.crmName
								this.let_data = result.data;
								if(result.data.defineFields !== '' && result.data.defineFields !== null && result.data.defineFields !== undefined){
									result.data.defineFields = JSON.parse(result.data.defineFields);
								}
								rows.data.forEach(item => {
									if (item.code.indexOf('Id') != '-1') {
										let tempname = item.code.substring(0,item.code.length - 2) + 'Name';
										this.$set(item, 'value', result.data[tempname])
									}else{
										this.$set(item, 'value', result.data[item.code])
										if(result.data.defineFields !== '' && result.data.defineFields !== null  && result.data.defineFields !== undefined){
											this.$set(item, 'values', result.data.defineFields[item.id])
										}
									}
								})
								this.results = rows.data;
							}
						})
					}
				})
			},
			
			// 联系人列表信息 
			contact(page,name_tab) {
				uni.showLoading({
					title: '加载中...'
				})
				list({source: 'linkMan'}).then((row) => {
					pages({
						'dtos': row.data,
						'crmType': this.action_id,
						'customerIds': this.uid,
						'isCollected': false,
						'type': 'linkMan',
						'page': {current: page, size: 20}
					}).then((val) => {
						if(val.code == 200){
							uni.hideLoading();
							if(!val.data.records.length && name_tab ==1){
								uni.showToast({
									title: '没有更多了',
									icon: 'error'
								}) 
							}
							if(this.contactname){
								for(let i in val.data.records){
									this.contactname.push(val.data.records[i])
								}
							}else{
								this.contactname = val.data.records;
							}
						}
					})
				})
			},
			
			// 跟进记录
			recordlist(page,name_tab) {
				uni.showLoading({
					title: '加载中...'
				})
				list({source: 'touch'}).then((rows) => {
					if(rows.code == 200){
						pages({crmType: this.action_id,customerIds: this.uid,dtos: rows.data,isCollected: false,page: {current: 1, size: 20},type: "touch"}).then((val) => {
							if(val.code == 200){
								uni.hideLoading();
								if(!val.data.records.length && name_tab == 1){
									uni.showToast({
										title: '没有更多了',
										icon: 'error'
									}) 
								}
								if(this.record_name){
									for(let i in val.data.records){
										this.record_name.push(val.data.records[i])
									}
								}else{
									this.record_name = val.data.records;
								}
							}
						})
					}
				})
		
				
				
			},
			
			// 商机列表
			inbus_list(id,type,page,name_tab){
				uni.showLoading({
					title: '加载中...'
				})
				list({source:'business'}).then((row)=>{
					if(row.code ==200){
						pages({crmType: type,customerIds: id,dtos: row.data,isCollected: false,'page': {current: page, size: 20}}).then((result) => {
								if(result.code == 200){
									uni.hideLoading();
									if(!result.data.records.length && name_tab == 1){
										uni.showToast({
											title: '没有更多了',
											icon: 'error'
										}) 
									}
									if(result.data.records.length > 0){
										for(let i in result.data.records){
											result.data.records[i]['tal'] = row.data
										}
										if(this.rundatas){
											for(let i in result.data.records){
												this.rundatas.push(result.data.records[i])
											}
										}else{
											this.rundatas = result.data.records;
										}
									}
								}
						})
					}
				})
			},
			
			// // 底部浮动操作
			// recorda(){
			// 	uni.navigateTo({  // 添加
			// 		url: '/pages/common/index/recordadd?id=' + this.uid + '&names=' + this.kehu_name + this
			// 			.url
			// 	})
			// },

			// 气泡弹窗操作
			tapPopup(val) {
				this.value = true;
				// 添加
				if (val.code == 1) {
					if (val.messing == "contactadd") {
						uni.navigateTo({
							url: '/pages/common/index/contactadd?id=' + this.uid + '&names=' + this.kehu_name +
								this.url
						})
					}
					if (val.messing == 'inbussadd') { // 商机添加
						this.url = '?classid=' + this.class_id + '&crmType=' + this.action_id + '&name=' + this.name + '&index=' + 3 + '&uid=' + this.uid + '&uname=' + this.let_data.crmName;
						// this.$refs.inbusadd.open('left')
						uni.navigateTo({
							url:'/pages/common/index/subpage/business/obj/businessadd' + this.url
						})
						
					}
					if(val.messing == 'recordadd'){
						uni.navigateTo({  // 跟进记录添加
							url: '/pages/common/index/recordadd?id=' + this.uid + '&names=' + this.kehu_name + this
								.url + '&street=' + this.citys
						})
					}
					
				}
				// 修改
				if (val.code == 2) {
					uni.navigateTo({
						url: '/pages/common/index/detialedit?id=' + this.uid + '&names=' + this.kehu_name + this
							.url
					})
				}
				
				// 删除
				if (val.code == 3) {
					delect({
						ids: this.uid,
						status: 2
					}).then((val) => {
						uni.showToast({
							title: '删除成功',
						})
						setTimeout(() => {
							uni.navigateTo({
								url: '/pages/common/index/second?id=' + this.class_id + '&name=' + this.name + '&crmType=' + this.action_id  
							});
						}, 1500)
					})

				}
				//关注
				if (val.code == 7) {
					collect([this.uid]).then((result) => {
						uni.showToast({
							title: '关注成功',
						})
						setTimeout(() => {
							uni.navigateTo({
								url: '/pages/common/index/second?id=' + this.class_id + '&crmType=' + this.action_id +
									'&name=' + this.name
							})
						}, 1500)
					})
				}
				//释放
				if (val.code == 6) {
					release([Number(this.uid)]).then((result) => {
						if (result.code == 200) {
							uni.showToast({
								title: '释放成功',
							})
							setTimeout(() => {
								uni.navigateTo({
									url: '/pages/common/index/second?id=' + this.class_id + '&crmType=' + this.action_id +
										'&name=' + this.name
								})
							}, 1500)
						}

					})
				}
				//领用
				if (val.code == 4) {
					receive([Number(this.uid)]).then((result) => {
						if (result.code == 200) {
							uni.showToast({
								title: '领用成功',
							})
							setTimeout(() => {
								uni.navigateTo({
									url: '/pages/common/index/second?id=' + this.class_id + '&crmType=' + this.action_id +
										'&name=' + this.name
								})
							}, 1500)
						}

					})
				}
				// 分配 
				if (val.code == 5) {
					this.$refs.popup.open('bottom')
				}
				// 成交
				if (val.code == 12) {
					dealSave([this.uid]).then((result) => {
						if (result.code == 200) {
							uni.showModal({
								title: '提示',
								content: '确定要转化为成交吗？',
								success: function(res) {
									if (res.confirm) {
										uni.showToast({
												title: '转化成功'
											}),
											setTimeout(() => {
												uni.navigateTo({
													url: '/pages/common/index/second?id=' + this.class_id + '&crmType=' + this.action_id +
														'&name=' + this.name
												})
											}, 1500)
									} else if (res.cancel) {
										console.log('用户点击取消');
									}
								}
							});

						}
					})
				}
				//共享
				if (val.code == 8) {
					this.$refs.alert.open('center')
				}
				//退回
				if (val.code == 11) {
					potentialSave([this.uid]).then((result) => {
						if (result.code == 200) {
							uni.showModal({
								title: '提示',
								content: '确定要退回吗',
								success(res) {
									if (res.confirm) {
										uni.showToast({
												title: '退回成功'
											}),
											setTimeout(() => {
												uni.navigateTo({
													url: '/pages/common/index/second?id=' + this.class_id + '&crmType=' + this.action_id +
														'&name=' + this.name
												})
											}, 1500)
									} else if (res.cancel) {
										console.log('点击取消');
									}
								}
							})

						}
					})
				}

			},
			// 内容切换
			changeTab(index) {
				this.talindex = index;
				this.data = [];
				let crmType = this.action_id;
				if (index == 0) {
					this.switch_one = true;
					this.switch_tow = false;
					this.switch_three = false;
					this.switch_five = false;
					this.switch_data(this.action_id,this.class_id);
					this.runt = 0;
					this.current = 0;
				}
				if (index == 1) {	// 联系人
					this.switch_one = false;
					this.switch_tow = true;
					this.switch_three = false;
					this.switch_five = false;
					if(crmType == 0){ // 公海
						this.get_userInfo([{title: "添加",messing: 'contactadd',code: 1,icon: 'icon-tubiao_tianjia',msag_code: 'crm:clue:linkMan:add'}])
					}
					if(crmType == 1){ // 潜在
						this.get_userInfo([{title: "添加",messing: 'contactadd',code: 1,icon: 'icon-tubiao_tianjia',msag_code: 'crm:potential:linkMan:add'}])
					}
					if(crmType == 2){ // 成交
						this.get_userInfo([{title: "添加",messing: 'contactadd',code: 1,icon: 'icon-tubiao_tianjia',msag_code: 'crm:deals:linkMan:add'}])
					}
					// this.rundatas = this.data;
					this.runt = 1;
					this.current = 1;
				}
				if (index == 2) {	// 联系记录
					this.switch_one = false;
					this.switch_tow = false;
					this.switch_three = true;
					this.switch_five = false;
					if(crmType == 0){ // 公海
						this.get_userInfo([{title: "添加",messing: 'recordadd',code: 1,icon: 'icon-tubiao_tianjia',msag_code: 'crm:clue:touch:add'}])
					}
					if(crmType == 1){ // 潜在
						this.get_userInfo([{title: "添加",messing: 'recordadd',code: 1,icon: 'icon-tubiao_tianjia',msag_code: 'crm:potential:touch:add'}])
					}
					if(crmType == 2){ // 成交
						this.get_userInfo([{title: "添加",messing: 'recordadd',code: 1,icon: 'icon-tubiao_tianjia',msag_code: 'crm:deals:touch:add'}])
					}
					// this.rundatas = this.data;
					this.runt = 2;
					this.current = 2;
				
				}

				if (index == 3) {	// 商机
					this.switch_one = false;
					this.switch_tow = false;
					this.switch_three = false;
					this.switch_five = true;
					if(crmType == 0){ // 公海
						this.get_userInfo([{title: "添加",messing: 'inbussadd',code: 1,icon: 'icon-tubiao_tianjia',msag_code: 'crm:clue:business:add'}])
					}
					if(crmType == 1){ // 潜在
						this.get_userInfo([{title: "添加",messing: 'inbussadd',code: 1,icon: 'icon-tubiao_tianjia',msag_code: 'crm:potential:business:add'}])
					}
					if(crmType == 2){ // 成交
						this.get_userInfo([{title: "添加",messing: 'inbussadd',code: 1,icon: 'icon-tubiao_tianjia',msag_code: 'crm:deals:business:add'}])
					}
					// this.rundatas = this.data;
					this.runt = 2;
					this.current = 3;
				}
			},
			//共享
			rundata(val) {
				val['ids'] = this.uid;
			},
			// 跳转(联系记录)
			record_details(val) {
				console.log(val)
				// if(val.type == 1){
					uni.navigateTo({
						url: "/pages/common/index/record?id=" + val.id + '&uid=' + this.uid + this.url + '&type=' + val.type
					})
				// }
				// else if(val.type == 2){
				// 	this.dataSorce = val.id;
				// 	this.$refs.recodelist.open('right')
				// }
			},
			
			recodlist(val){
				if(val == 1){
					this.$refs.recodelist.close();
					location.reload();
				}else{
					
					this.$refs.recodelist.close();
				}
			},
			
			// 外勤打卡
			recodesigns(){
				this.url = '&classid=' + this.class_id + '&crmType=' + this.action_id + '&name=' + this.name + '&index=' + 2;
				this.$refs.recode.open('left');
			},
			
			// 签到弹窗关闭
			recodecolos(val){
				if(val == 1){
					this.$refs.recode.close();
					location.reload();
				}else{
					this.$refs.recode.close();
				}
			},
			//	关闭商机添加弹窗 inbusadd
			inbusaddclose(val){
				if(val == 1){
					this.$refs.inbusadd.close();
					location.reload();
				}else{
					this.$refs.inbusadd.close();
				}
			}
		}
	}
</script>

<style scoped lang="scss">
	// 基本资料css
	.detial {
		height: 100%;
		padding-top: 95rpx;
		width: 100%;
		background-color: #fff;

		.detial_text {
			width: 95%;
			margin: auto;
			height: 60rpx;
			line-height: 60rpx;
			overflow: hidden;
			text-overflow: ellipsis;
			white-space: nowrap;
			background-color: #fff;
		}

		.detial_text text {
			padding-left: 30rpx;
			color: #808080;
		}

		.detial_text span {
			padding-left: 30rpx;
		}
	}

	.stats {
		width: 200px;
		height: 100rpx;
		z-index: 1;
	}

	.title {
		margin-top: 1px;
		height: 90rpx;
		background-color: #fff;
		line-height: 90rpx;
		padding-left: 10px;
		border-bottom: 1px solid #f0f0f0;
		border-radius: 4px;
	}

	.second_list {
		height: 90rpx;
		margin-top: 1px;
		background-color: #fff;
		line-height: 90rpx;
		padding-left: 20px;
		border-radius: 4px;

	}

	.public_left {
		margin-left: -30px;
	}

	// 联系人css

	.conten {
		width: 95%;
		margin: auto;
		border-bottom: 1px solid #f0f0f0;
		div {
			display: flex;
			// justify-content: space-between;
			height: 60rpx;
			// border-bottom: 1px solid #f0f0f0;

			text {
				width: 50%;
				padding-left: 30rpx;
				line-height: 60rpx;
			}
		}

		.conten_phone {
			overflow: hidden;
			width: 95%;
		}
	}

	.div_h {
		border: 3px solid #f0f0f0;
	}

	// 联系人弹窗css
	.staff {
		background-color: #fff;
		height: 800rpx;
		border-radius: 4px;

		.staff_b {
			height: 85%;

			// overflow: auto;
			.staff_list {
				width: 90%;
				text-align: center;
				margin: auto;
				padding: 20rpx 0 20rpx 0;
				border-bottom: 1px solid #f0f0f0;
			}
		}

		.staff_button {
			display: flex;
			padding: 20rpx 0 0 0;
			width: 100%;
			border-top: 1px solid #f0f0f0;

			button {
				font-size: 16px;
				width: 100%;
				background-color: #1890ff;
				color: #fff;
			}
		}
	}


	// 联系记录

	.record {
		// padding: 3px 0  10px 30rpx;
		
	}
	.record_div_one{
		border-bottom: 5px solid #F1F1F1;
		text {
			padding: 0 0 0 30rpx;
		}
	}
	.record_text {
		overflow: hidden;
		view {
			width: 50%;
		}
	}

	.record_txt {
		width: 95%;
		margin: auto;
		padding: 0 0 10px 50rpx;
	}


	.record_public {
		width: 95%;
		margin: auto;
		height: 50rpx;
		line-height: 50rpx;
		overflow: hidden;
		.record_public_text {
			float: right;
			padding: 0 50rpx 0 30rpx;
			font-size: 14px;
			color: #9e9e9e;
		}
	}

	.record_dispaly {
		display: flex;
	}
	
	.record_bottom {
		width: 100%;
		height: 110rpx;
		position: fixed;
		bottom: 0;
		background-color: #1890FF;
		div {
			width: 95%;
			margin: auto;
			display: flex;
			line-height: 110rpx;
			font-size: 20px;
			color: #fff;
			justify-content: space-around;
		}
	}

	// 点击样式
	.public_color {
		color: #808080;
	}
	
	
	.secode_uot {
		width: 95%;
		margin: auto;
		padding-bottom: 10px;
		padding-left: 30rpx;
		.secode_img {
			display: flex;
			image {
				width: 40px;
				height: 40px;
				border-radius: 50%;
			}
			div {
				text {
					padding-left: 30rpx;
				}
			}
			.secode_ph {
				width: 40px;
				height: 40px;
				border-radius: 50%;
				text-align: center;
				line-height: 40px;
				font-size: 12px;
				background-color: #a94cd9ab;
				color: #fff;
			}
		}
		.secode_class{
			border-bottom: 1px solid #cacaca;
			padding: 5px 0 5px 30rpx;
		}
		.secode_text {
			div{
				text-align: left;
				height: 40px;
				line-height: 40px;
				padding-left: 30rpx;
				overflow: hidden;
			}
		}
	
	}
</style>
